package com.example.config;

import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import com.example.sentinel.GlobalExceptionHandler;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName WebConfig
 * @Description TODO
 * @Author: XMK
 * @Date: 2020/4/29 10:06
 * @Version: 1.0
 */
@Configuration
public class WebConfig {

    @Bean
    @LoadBalanced
    @SentinelRestTemplate(blockHandler = "handleBlock", blockHandlerClass = GlobalExceptionHandler.class,
            fallback = "handleFallback", fallbackClass = GlobalExceptionHandler.class)
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
